package com.central.scheduler.api.service;

import com.central.common.model.Result;
import com.central.common.model.SysUser;
import com.central.scheduler.api.enums.ExecuteType;
import com.central.scheduler.common.enums.*;
import com.central.scheduler.dao.model.ProcessDefinition;

import java.util.Map;

/**
 * @author Tindy
 * @date 2021/12/15
 * @describe
 */
public interface IExecutorService {

    /**
     * execute process instance
     *
     * @param user
     * @param processDefinitionCode     process definition code
     * @param cronTime                  cron time
     * @param commandType               command type
     * @param failureStrategy           failuer strategy
     * @param startNodeList             start nodelist
     * @param taskDependType            node dependency type
     * @param warningType               warning type
     * @param warningGroupId            notify group id
     * @param processInstancePriority   process instance priority
     * @param runMode                   run mode
     * @param timeout                   timeout
     * @param startParams               the global param values which pass to new process instance
     * @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode
     * @return execute process instance code
     */
    Result execProcessInstance(SysUser user, Long processDefinitionCode, String cronTime, CommandType commandType,
                               FailureStrategy failureStrategy, String startNodeList,
                               TaskDependType taskDependType, WarningType warningType, Long warningGroupId,
                               RunMode runMode, Priority processInstancePriority,Integer timeout,
                               Map<String, String> startParams, Integer expectedParallelismNumber, Integer dryRun);
    /**
     * check whether the process definition can be executed
     *
     *
     * @param processDefinition process definition
     * @return check result code
     */
    Result checkProcessDefinitionValid(ProcessDefinition processDefinition);

    Result execute(SysUser user, Long processInstanceId, ExecuteType executeType);

}